Skip to content

Add upgrade e2e test and fix PackageUpgradedEvent parsing#456

Open
Bridgerz wants to merge 2 commits intomainfrom
upgrade-test-infrastructure
Open

Add upgrade e2e test and fix PackageUpgradedEvent parsing#456
Bridgerz wants to merge 2 commits intomainfrom
upgrade-test-infrastructure

Conversation

@Bridgerz
Copy link
Copy Markdown
Contributor

Summary

  • Adds an e2e test that exercises the full governance-gated upgrade lifecycle and verifies cascading effects
  • Fixes a bug: PackageUpgradedEvent was missing from HashiEvent::try_parse(), so validators never learned about package upgrades via the event stream — only on full rescrape

Bug fix

PackageUpgradedEvent had a struct definition, MoveType impl, and was handled in the watcher's event loop (watcher.rs:228), but was never added to the try_parse() match arms in move_types/mod.rs. The event was silently dropped at the catch-all _ => return Ok(None). After an upgrade, validators would not update their package version map until a subscription reconnect triggered a full rescrape.

Test details

The test programmatically patches the deployed package at test time (bumps PACKAGE_VERSION, injects a canary module), then verifies:

  1. Watcher picks up new package — all 4 nodes detect the new version via PackageUpgradedEvent
  2. Package ID routingOnchainState.package_id() returns the new package on all nodes
  3. Validator deposit confirmation — full deposit flow (BTC send → mine → request → validator auto-confirm) works against the upgraded package
  4. New code reachable — v2-only canary module is callable
  5. Version gating — disabling v1 rejects old entry points with EVersionDisabled

Files changed

  • crates/hashi-types/src/move_types/mod.rs — add PackageUpgradedEvent to try_parse()
  • crates/e2e-tests/src/upgrade_flow.rs — upgrade helpers (prepare, build, propose/vote/execute, disable)
  • crates/e2e-tests/src/upgrade_tests.rs — the e2e test
  • crates/e2e-tests/src/lib.rs — module declarations + dir() accessor

Test plan

  • cargo test -p e2e-tests -- test_upgrade_v1_to_v2 --ignored — passes in ~44s
  • cargo check -p hashi — compiles clean

@Bridgerz Bridgerz requested a review from bmwill as a code owner April 15, 2026 19:25
@Bridgerz Bridgerz force-pushed the upgrade-test-infrastructure branch 3 times, most recently from 2dc5423 to 0403601 Compare April 15, 2026 20:41
Comment thread crates/e2e-tests/src/upgrade_tests.rs Outdated
Comment thread crates/e2e-tests/src/upgrade_tests.rs Outdated
Comment thread crates/e2e-tests/src/upgrade_tests.rs Outdated
Comment thread crates/e2e-tests/src/upgrade_flow.rs
Comment thread crates/e2e-tests/src/upgrade_tests.rs Outdated
Comment thread crates/e2e-tests/src/upgrade_flow.rs
@Bridgerz Bridgerz force-pushed the upgrade-test-infrastructure branch 2 times, most recently from 42de78f to b2b4f6d Compare April 15, 2026 23:46
Adds an end-to-end test that exercises the full governance-gated upgrade
lifecycle and verifies cascading effects across the stack.

The test found a real bug: PackageUpgradedEvent was missing from
HashiEvent::try_parse(), so validators never learned about package
upgrades via the event stream. Fixed by adding the missing match arm.

Test flow:
- Deposit before upgrade, verify balance survives (state continuity)
- Upgrade via propose/vote/execute+publish+finalize
- Verify all node watchers pick up the new package version
- Deposit after upgrade through full validator confirmation path
- Call v2-only canary module (new code reachable)
- Disable v1, verify entry points rejected
Most of upgrade_flow.rs was either generic proposal-flow plumbing or
upgrade-specific PTB construction — neither of which needs to live in
the test crate. Pulls the non-test pieces into the hashi crate so both
the e2e harness and the CLI can share them.

New `hashi::cli::upgrade` module with:
  - build_upgrade_package — wraps `sui move build --dump-bytecode-as-base64`
    and parses the output into a Publish + digest.
  - build_upgrade_execution_transaction — constructs the
    `execute + publish + finalize` PTB the upgrade proposal requires.
  - build_execute_proposal_transaction — generic non-upgrade proposal
    execution; takes execute_package_id separately so post-upgrade
    disable_version still routes through the new package.
  - extract_proposal_id_from_response — parse ProposalCreatedEvent.
  - extract_new_package_id_from_response — find the new package in the
    upgrade tx effects.

In `hashi::cli::client`:
  - Replace the UpdateConfig-specific build_vote_update_config_transaction
    / build_execute_update_config_transaction with a generic standalone
    build_vote_transaction. HashiClient::build_vote_transaction now
    delegates to it, removing the duplicate PTB construction.

The e2e `upgrade_flow.rs` and the TestNetworksBuilder on-chain config
override flow now go through these helpers, which drops ~300 lines of
duplicated PTB boilerplate and inline event parsing.

No behaviour change; no new CLI commands are wired up yet. Follow-up
work on the cli-governance-improvements branch will add pre-flight
checks (version +1 enforcement, quorum readiness, etc.) and an
execute-upgrade CLI command that uses these helpers.
@Bridgerz Bridgerz force-pushed the upgrade-test-infrastructure branch from cdfb5b6 to f6a8afd Compare April 16, 2026 00:09
@Bridgerz
Copy link
Copy Markdown
Contributor Author

@bmwill this is ready for another round!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants